Android Things Quick Start Guide by Raul Portales
Author:Raul Portales
Language: eng
Format: epub, pdf
Tags: COM067000 - COMPUTERS / Hardware / General, COM025000 - COMPUTERS / Expert Systems, COM046070 - COMPUTERS / Operating Systems / Linux
Publisher: Packt Publishing
Published: 2018-08-31T13:53:59+00:00
public static Button openButton(String pin) throws IOException {
return new Button(pin, BUTTON_LOGIC_STATE);
}
Since we are using a driver, this step is very simple; the only thing the meta driver hides from us is the logic state of the buttons. Since they are capacitive, they are pressed when the GPIO is low (which is the reverse of normal press buttons). This is the equivalent of the active type we saw with inputs in the previous section.
So, if we just put everything together, we can just collapse it on a single line:
buttonA = Button(BoardDefaults.buttonA, Button.LogicState.PRESSED_WHEN_LOW)
And then, just for completeness, we add a new value to the BoardDefaults object for the pin where the button is connected:
val buttonA: String
get() = when (Build.DEVICE) {
DEVICE_RPI3 -> "BCM21"
DEVICE_IMX7D_PICO -> "GPIO6_IO14"
else -> throw IllegalStateException("Unknown Build.DEVICE ${Build.DEVICE}")
}
Let's take the example of the previous chapter that used a button and an LED and see how it will look when we completely remove the abstraction for the Rainbow HAT:
class ButtonDriverActivity : Activity() {
Download
Android Things Quick Start Guide by Raul Portales.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(27094)
Hello! Python by Anthony Briggs(25947)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(25285)
Kotlin in Action by Dmitry Jemerov(24393)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(23591)
Dependency Injection in .NET by Mark Seemann(23313)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21944)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20848)
Grails in Action by Glen Smith Peter Ledbrook(19869)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17072)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16832)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14464)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12582)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11865)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10650)
Hit Refresh by Satya Nadella(9236)
The Kubernetes Operator Framework Book by Michael Dame(8588)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8445)
Robo-Advisor with Python by Aki Ranin(8387)